#pragma once
#include "datastore.h"

#include "GDSA.h"
#include "GMap.h"
#include "GSpectForm.h"
// WaveAnalysisCtrl.h : Declaration of the CWaveAnalysisCtrl ActiveX Control class.


// CWaveAnalysisCtrl : See WaveAnalysisCtrl.cpp for implementation.

class CWaveAnalysisCtrl : public COleControl
{
	DECLARE_DYNCREATE(CWaveAnalysisCtrl)

// Constructor
public:
	CWaveAnalysisCtrl();

// Overrides
public:
	virtual void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid);
	virtual void DoPropExchange(CPropExchange* pPX);
	virtual void OnResetState();

// Implementation
protected:
	~CWaveAnalysisCtrl();

	DECLARE_OLECREATE_EX(CWaveAnalysisCtrl)    // Class factory and guid
	DECLARE_OLETYPELIB(CWaveAnalysisCtrl)      // GetTypeInfo
	DECLARE_PROPPAGEIDS(CWaveAnalysisCtrl)     // Property page IDs
	DECLARE_OLECTLTYPE(CWaveAnalysisCtrl)		// Type name and misc status

// Message maps
	DECLARE_MESSAGE_MAP()

// Dispatch maps
	DECLARE_DISPATCH_MAP()

// Event maps
	DECLARE_EVENT_MAP()

// Dispatch and event IDs
public:
	enum {
		dispidSetPagebyOffset = 14L,
		dispidSetDSALayout = 13L,
		dispidDrawToFile = 12L,
		dispidSetChannelName = 11L,
		dispidStartCalc = 10L,
		dispidSwitchViewType = 9L,
		dispidSetSamplingRate = 8L,
		dispidUpdateEverything = 7L,
		dispidSetMode = 6L,
		dispidCleanAll = 5L,
		dispidAddData = 4L,
		dispidEndChannel = 3L,
		dispidAddChannel = 2L,
		dispidInitAx = 1L
	};

protected:
	DataStore ds;
	GDSA* gdsa;
	GSpectForm *gsf;
	GMap *gmap;
	int GType;
public:
	void InitAx(void);
	void AddChannel(SHORT eid);
protected:
	SHORT EndChannel(void);
	void AddData(DOUBLE x);
	void CleanAll(void);
	void SetMode(USHORT mode);
	void UpdateEverything(void);
public:
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
protected:
	void SetSamplingRate(ULONG sr);
	void SwitchViewType(SHORT type);
	ULONG StartCalc(void);
	void SetChannelName(LPCTSTR name);
	void DrawToFile(LPCTSTR filename, USHORT format, SHORT ch,unsigned long w,unsigned long h);
public:
//	afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnGsfMaximun();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnGsfExport();
	afx_msg void OnGsf1Exportdata();
	afx_msg void OnGsf1Saveasbmp();
	afx_msg void OnDestroy();
protected:
	void SetDSALayout(USHORT layout);
public:
	afx_msg void OnGsf1Info();
protected:
	LONG SetPagebyOffset(SHORT offset);
};

